﻿Imports System.Windows.Forms

Public Class DatagridViewEdComboBoxCell
    Inherits DataGridViewTextBoxCell

    Public Overrides Sub InitializeEditingControl(rowIndex As Integer, initialFormattedValue As Object, dataGridViewCellStyle As System.Windows.Forms.DataGridViewCellStyle)
        MyBase.InitializeEditingControl(rowIndex, initialFormattedValue, dataGridViewCellStyle)
        Dim eControl As DatagridViewEdComboBoxEditingControl = Me.DataGridView.EditingControl
        Dim eColumn As DatagridViewEdComboBoxColumn = Me.OwningColumn

        eControl.Items.Clear()
        For Each s As String In eColumn.Items
            eControl.Items.Add(s)
        Next
        If TypeOf (Me.Value) Is System.DBNull Then
            eControl.Text = ""
        Else
            eControl.Text = Me.Value
        End If

    End Sub

    Public Overrides ReadOnly Property EditType As System.Type
        Get
            Return GetType(DatagridViewEdComboBoxEditingControl)
        End Get
    End Property

End Class
